package com.myaihui.service.impl;


import com.myaihui.domain.Park;
import com.myaihui.foundation.model.Pager;
import com.myaihui.foundation.query.ParkQuery;
import com.myaihui.foundation.vo.ParkPageVo;
import com.myaihui.repository.ParkRepository;
import com.myaihui.service.ParkService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * *******************************
 * Created by Tim.
 * form com.myaihui
 * on 2018/5/31
 * *******************************
 */
@Service
public class ParkServiceImpl implements ParkService {
    @Autowired
    private ParkRepository parkRepository;

    @Override
    public Pager<ParkPageVo> getParkPage(ParkQuery parkQuery) {
        return null;
    }

    @Override
    public Park get(String id) {
        return parkRepository.getOne(id);
    }

    @Override
    public Park modify(Park park) {
        if (StringUtils.isNotBlank(park.getId())) {
            Park oldPark = parkRepository.findOne(park.getId());
            oldPark.setId(park.getId());
            return parkRepository.save(oldPark);
        }
        return parkRepository.save(park);
    }
}